<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="common/include :: header('新增客户联系人')" />
</head>
<body class="white-bg">
	<div class="wrapper wrapper-content animated fadeInRight ibox-content">
		<form class="form-horizontal m" id="form-post-add">
			<div class="form-group">
				<label class="col-sm-3 control-label is-required">客户姓名：</label>
				<div class="col-sm-8">
					<select class="form-control" name="customerId" >
						<option value="">请选择</option>
						<option th:each="dict : ${customerList}" th:text="${dict.customerName}" th:value="${dict.id}"></option>
					</select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label is-required">联系人姓名：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="linkman" id="postCode" required>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label is-required">性别：</label>
				<div class="col-sm-8">
					<select class="form-control" name="gender" th:with="type=${@dict.getType('sys_user_sex')}">
						<option th:each="dict : ${type}" th:text="${dict.label}" th:value="${dict.value}"></option>
					</select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label is-required">年龄：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="age" id="postCode" required>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label is-required">电话：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="phone" id="postCode" required>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label is-required">职位：</label>
				<div class="col-sm-8">
					<select class="form-control" name="position">
						<option value="">请选择</option>
						<option th:each="dict : ${positionList}" th:text="${dict.name}" th:value="${dict.id}"></option>
					</select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label is-required">部门：</label>
				<div class="col-sm-8">
					<select class="form-control" name="department" >
						<option value="">请选择</option>
						<option th:each="dict : ${departmentList}" th:text="${dict.name}" th:value="${dict.id}"></option>
					</select>
				</div>
			</div>
		</form>
	</div>
	<th:block th:include="common/include :: footer" />
	<th:block th:include="common/include :: datetimepicker" />
	<script type="text/javascript">


		var prefix = ctx + "/business/customerLinkmen";
		/*$('#form-post-add').bootstrapValidator({
//        live: 'disabled',
			message: 'This value is not valid',
			feedbackIcons: {
				valid: 'glyphicon glyphicon-ok',
				invalid: 'glyphicon glyphicon-remove',
				validating: 'glyphicon glyphicon-refresh'
			},
			fields: {
				linkman:{
					validators:{ // 验证的规则
						notEmpty:{ // 不能为空
							message:"姓名必填" // 错误时的提示信息
						},
						stringLength: { // 字符串的长度范围
							min: 1,
							max: 5
						},
						/!*remote: { // 远程验证
							type: 'get', // 请求方式
							url: '/employee/checkUserName', // 请求地址
							message: '用户名已经存在', // 验证不通过时的提示信息
							delay: 1000, // 输入内容 1 秒后发请求
						}*!/
					}
				},
				phone:{
					validators:{ // 验证的规则
						notEmpty:{ // 不能为空
							message:"电话必填" // 错误时的提示信息
						},
						stringLength: { // 字符串的长度范围
							min: 1,
							max: 20
						}
					}
				},
				password:{
					validators:{
						notEmpty:{ // 不能为空
							message:"密码必填" // 错误时的提示信息
						},
					}
				},
				repassword:{
					validators:{
						notEmpty:{ // 不能为空
							message:"密码必填" // 错误时的提示信息
						},
						identical: {// 两个字段的值必须相同
							field: 'password',
							message: '两次输入的密码必须相同'
						},
					}
				},
				email: {
					validators: {
						emailAddress: {} // 邮箱格式
					}
				},
				age:{
					validators: {
						between: { // 数字的范围
							min: 18,
							max: 60
						}
					}
				}
			}
		}).on('success.form.bv', function(e) {
			$('.selfRoles > option').prop('selected', 'true');

		});*/
	    
		/*$("#form-post-add").validate({
			onkeyup: false,
			rules:{
				name:{
					remote: {
		                url: prefix + "/checkPostNameUnique",
		                type: "post",
		                dataType: "json",
		                data: {
		                	"name" : function() {
		                        return $.common.trim($("#postName").val());
		                    }
		                },
		                dataFilter: function(data, type) {
		                	return $.validate.unique(data);
		                }
		            }
				},
				code:{
					remote: {
		                url: prefix + "/checkPostCodeUnique",
		                type: "post",
		                dataType: "json",
		                data: {
		                	"code" : function() {
		                        return $.common.trim($("#postCode").val());
		                    }
		                },
		                dataFilter: function(data, type) {
		                	return $.validate.unique(data);
		                }
		            }
				},
				postSort:{
					digits:true
				},
			},
			messages: {
		        "code": {
		            remote: "服务编码已经存在"
		        },
		        "name": {
		            remote: "服务名称已经存在"
		        }
		    },
		    focusCleanup: true
		});*/
		
		function submitHandler() {
	        if ($.validate.form()) {
	        	$.operate.save(prefix + "/add", $('#form-post-add').serialize());
	        }
	    }
	</script>
</body>
</html>
